<template>
  <div class="list-wrap-box">
    <PatentModeA
      v-if="ctNavID === 'patent'"
      :data="data"
      :emptyText="emptyText"
      :checkAllVal="checkAllVal"
    />
    <LiteratureModeA
      v-if="ctNavID === 'paper'"
      :data="data"
      :emptyText="emptyText"
      :checkAllVal="checkAllVal"
    />
    <AchievementsModeA
      v-if="ctNavID === 'achieve'"
      :data="data"
      :emptyText="emptyText"
      :checkAllVal="checkAllVal"
    />
    <ProjectsModeA
      v-if="ctNavID === 'project'"
      :data="data"
      :emptyText="emptyText"
      :checkAllVal="checkAllVal"
    />
    <StandardModeA
      v-if="ctNavID === 'standard'"
      :data="data"
      :emptyText="emptyText"
      :checkAllVal="checkAllVal"
    />
  </div>
</template>

<script>
import { deleteTag } from "@/utils/utils.js";
import PatentModeA from "./components/PatentModeA.vue";
import LiteratureModeA from "./components/LiteratureModeA.vue";
import AchievementsModeA from "./components/AchievementsModeA.vue";
import ProjectsModeA from "./components/ProjectsModeA.vue";
import StandardModeA from "./components/StandardModeA.vue";

export default {
  props: {
    ctNavID: {
      type: String,
    },
    data: {
      type: Object,
    },
    emptyText: {
      type: String,
    },
    checkAllVal: {
      type: Boolean,
    },
  },
  components: {
    PatentModeA,
    LiteratureModeA,
    AchievementsModeA,
    ProjectsModeA,
    StandardModeA,
  },
  data() {
    return {};
  },
  methods: {},
  mounted() {
    // 收藏
    this.$Bus.$on("collect", (param) => {
      if (param.type == "collect") {
        param.title = deleteTag(param.title);
        param.userId = JSON.parse(localStorage.getItem("homeUserInfo")).id;
        this.$post(this.$Url.collect.collectionAdd, param).then((res) => {
          this.$message({
            type: "success",
            message: "收藏成功！",
          });
          this.$Bus.$emit("isCollect", {
            type: "success",
            collectionId: res.data,
          });
        });
      } else {
        this.$confirm("您确定取消收藏吗？", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
        }).then(() => {
          this.$delete(
            `${this.$Url.collect.collectionDelete}/${param.sourceId}`,
            {}
          ).then((res) => {
            this.$message({
              type: "success",
              message: "取消成功！",
            });
            this.$Bus.$emit("isCollect", {
              type: "fail",
            });
          });
        });
      }
    });
  },
};
</script>

<style lang="scss" scoped>
.list-wrap-box {
  position: relative;
}
</style>
